<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
	default-lazy-init="true">

	<context:property-placeholder location="classpath*:/finalist.properties" ignore-resource-not-found="true" ignore-unresolvable="true" />

	<context:component-scan base-package="com.finalist,com.rainy.**.controller" use-default-filters="false">
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
	</context:component-scan>

	<mvc:annotation-driven validator="validator" />

	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/order/**" />
			<mvc:mapping path="/member/**" />
			<bean id="memberInterceptor" class="com.finalist.interceptor.MemberInterceptor" />
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/payment/**" />
			<mvc:exclude-mapping path="/common/weixin/**" />
			<mvc:exclude-mapping path="/travel/weixin/**" />
			<bean id="tokenInterceptor" class="com.finalist.interceptor.TokenInterceptor" />
		</mvc:interceptor>
		<!-- 
		<mvc:interceptor>
			<mvc:mapping path="/admin/**" />
			<bean id="executeTimeInterceptor" class="com.finalist.interceptor.ExecuteTimeInterceptor" />
		</mvc:interceptor>
		-->
		<mvc:interceptor>
			<mvc:mapping path="/admin/**" />
			<bean id="webContentInterceptor" class="org.springframework.web.servlet.mvc.WebContentInterceptor">
				<property name="cacheSeconds" value="0" />
			</bean>
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/common/weixin/**" />
			<bean id="openSessionInViewInterceptor" class="org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor">
				<property name="entityManagerFactory" ref="entityManagerFactory" />
			</bean>
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/admin/**" />
			<bean id="listInterceptor" class="com.finalist.interceptor.ListInterceptor" />
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/admin/**" />
			<bean id="logInterceptor" class="com.finalist.interceptor.LogInterceptor" />
		</mvc:interceptor>
		
		<mvc:interceptor>
			<mvc:mapping path="/travel/weixin/**" />
			<bean id="weixinInterceptor" class="com.finalist.interceptor.WeixinInterceptor" />
		</mvc:interceptor>
		
	</mvc:interceptors>

	<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
		<property name="validationMessageSource" ref="messageSource" />
		<property name="traversableResolver">
	        <bean class="com.finalist.ExtTraversableResolver"></bean>
	    </property>
	</bean>

	<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
		<property name="contentType" value="text/html; charset=UTF-8" />
		<property name="suffix" value="${template.suffix}" />
	</bean>

	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="defaultEncoding" value="UTF-8" />
	</bean>

	<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
		<property name="defaultErrorView" value="shop/common/error" />
	</bean>

</beans>